Skip to content

refactor: scope the access-token required-flag skip per command - #748

Open
ffantl-ld wants to merge 1 commit into
mainfrom
ffantl/prerun-flag-skip
Open

refactor: scope the access-token required-flag skip per command#748
ffantl-ld wants to merge 1 commit into
mainfrom
ffantl/prerun-flag-skip

Conversation

@ffantl-ld

@ffantl-ld ffantl-ld commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Describe the solution you've provided

Commands that don't need an API token (completion, config, help, login, signup, whoami) previously skipped the required --access-token check by setting DisableFlagParsing = true. That also suppressed validation of the subcommand's own required flags.

This clears the --access-token required annotation on the specific flag instead, so those commands still parse and validate their own flags.

Related issues

Groundwork for the guided setup command (which also needs to run without a token). Split out so it can land and release on its own merit.

Additional context

Behavior-only change to cmd/root.go; no new packages.


Note

Low Risk
Localized CLI startup behavior in root PersistentPreRun; no API, auth, or data-path changes beyond fixing flag validation for exempt commands.

Overview
Auth-exempt commands (completion, config, help, login, signup, whoami and their subcommands) no longer set DisableFlagParsing, which was skipping validation for all flags on those commands.

Instead, PersistentPreRun calls clearAccessTokenRequirement, which walks the command’s parent chain and removes Cobra’s required annotation on the persistent --access-token flag when the command tree is under an exempt name. Global flag parsing and subcommand-specific required flags still run as usual.

Reviewed by Cursor Bugbot for commit fcf935d. Bugbot is set up for automated code reviews on this repo. Configure here.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ffantl-ld
ffantl-ld force-pushed the ffantl/prerun-flag-skip branch from 3d1d7ad to fcf935d Compare July 23, 2026 15:15
@ffantl-ld
ffantl-ld marked this pull request as ready for review July 27, 2026 17:23
@ffantl-ld
ffantl-ld requested review from Vadman97 and erangeles July 27, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant